<template>
  <view class="publishDemand">
    <uni-forms ref="valiForm" :rules="rules" :modelValue="valiFormData">
      <view class="publishDemand-content">
        <view class="formLabel no-border uni-flex border-bottom">
          <text>姓名</text>
          <uni-forms-item name="name">
            <uni-easyinput class="my-input" v-model="valiFormData.name" placeholder="请输入持卡人姓名" />
          </uni-forms-item>
        </view>
        <view class="formLabel no-border uni-flex">
          <text>身份证</text>
          <uni-forms-item name="people">
            <uni-easyinput class="my-input" v-model="valiFormData.people" placeholder="请输入身份证号码" />
          </uni-forms-item>
        </view>
      </view>
      <view class="publishDemand-content">
        <view class="formLabel no-border uni-flex uni-align-center border-bottom bankCode">
          <text>银行卡号</text>
          <uni-forms-item name="address">
            <uni-easyinput class="my-input" v-model="valiFormData.address" placeholder="请输入银行卡号" />
          </uni-forms-item>
          <uni-icons type="camera" size="30" style="margin-left: 24rpx" color="#999999" @click="showBankcard"></uni-icons>
        </view>
        <view class="formLabel no-border uni-flex border-bottom uni-justify-between bankCode">
          <text>卡类型</text>
          <view class="uni-flex uni-align-center">
            <view class="slectBank">请选择开户银行</view>
            <uni-icons type="right" size="15" style="margin-left: 41rpx" color="#666666" @click="showBankcard"></uni-icons>
          </view>
        </view>
        <view class="formLabel no-border uni-flex border-bottom">
          <text>银行预留手机号</text>
          <uni-forms-item name="tel">
            <uni-easyinput class="my-input" v-model="valiFormData.tel" placeholder="请输入手机号码" />
          </uni-forms-item>
        </view>
        <view class="formLabel no-border uni-flex bankCode">
          <text>验证码</text>
          <uni-forms-item name="tel">
            <uni-easyinput class="my-input" v-model="valiFormData.tel" placeholder="请输入验证码" />
          </uni-forms-item>
          <view class="help-text" @click="getTel">获取验证码</view>
        </view>
      </view>
    </uni-forms>

    <view class="publishDemand-button" @click="submit('valiForm')">提交绑定</view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      isChecked: false,
      // 校验表单数据
      valiFormData: {
        name: "",
        age: "",
        introduction: "",
        date: ["2021-3-20", "2021-5-20"],
        people: "",
        money: "",
        address: "",
        account: "",
        tel: ""
      },
      // 校验规则
      rules: {
        name: {
          rules: [
            {
              required: true,
              errorMessage: "标题不能为空"
            }
          ]
        },
        introduction: {
          rules: [
            {
              required: true,
              errorMessage: "岗位详情不能为空"
            }
          ]
        }
      },
      tags: [
        { name: "零工", id: 1 },
        { name: "小时工", id: 2 },
        { name: "临时工", id: 3 },
        { name: "学生工", id: 4 },
        { name: "全职", id: 5 },
        { name: "兼职", id: 6 },
        { name: "实习", id: 7 },
        { name: "其他", id: 8 }
      ]
    };
  },
  methods: {
    onCheckChange() {
      this.isChecked = !this.isChecked;
    },
    toggleTag(tag) {
      const index = this.tags.indexOf(tag);
      if (index > -1) {
        this.tags.splice(index, 1);
      } else {
        this.tags.push(tag);
      }
    },
    addLabel() {
      if (this.newLabel) {
        this.tags.push({ name: this.newLabel });
        this.newLabel = "";
      }
    },
    isSelected(tag) {
      return this.tags.indexOf(tag) > -1;
    },
    submit() {
    
    }
  }
};
</script>
<style lang="scss">
.formLabel {
  .uni-forms-item {
    flex: 1;
    margin-bottom: 30rpx;
  }
}

.bankCode {
  padding-bottom: 20rpx;
  .uni-forms-item {
    flex: 1;
    margin-bottom: 0rpx;
  }
}

.no-border {
  .uni-forms-item__content .is-input-border {
    border: none !important;
    font-size: 28rpx;
    margin-top: 6rpx;
    text-align: right;
  }
}
</style>

<style scoped lang="scss">
.publishDemand {
  padding: 26rpx 24rpx 81rpx;
  background: #f5f5f5;
  min-height: calc(100vh - 26rpx);

  .publishDemand-content {
    background: #ffffff;
    border-radius: 20rpx;
    padding: 34rpx 26rpx 0 23rpx;
    margin-bottom: 24rpx;

    .no-border {
      margin-bottom: 29rpx;
    }
    .border-bottom {
      border-bottom: 1px solid #e2e2e2;
    }

    .formLabel {
      .slectBank {
        font-weight: 400;
        font-size: 28rpx;
        color: #999999;
      }
      .help-text {
        background: #b3d3ff;
        border-radius: 34rpx;
        font-weight: 400;
        font-size: 28rpx;
        color: #fff;
        width: 200rpx;
        height: 67rpx;
        text-align: center;
        line-height: 67rpx;
        margin-left: 44rpx;
      }
      text {
        font-weight: 500;
        font-size: 28rpx;
        color: #303133;
        line-height: 80rpx;
      }
    }
  }

  .publishDemand-button {
    width: 86%;
    height: 88rpx;
    background: #2f80ed;
    border-radius: 44rpx;
    text-align: center;
    font-weight: 600;
    font-size: 30rpx;
    color: #ffffff;
    line-height: 88rpx;
    margin: 0 auto;
    margin-top: 192rpx;
  }
}
</style>
